#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/select.h>
int main()
{
    int server = socket(AF_INET, SOCK_STREAM, 0);
    struct sockaddr_in  servaddr;
    memset(&servaddr, 0, sizeof(servaddr));
    
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    servaddr.sin_port = htons(55001);
    
    bind(server, (struct sockaddr*)&servaddr, sizeof(servaddr));
    listen(server, 5);
    
    int client = accept(server,  (struct sockaddr*)NULL, NULL);
    char msg[1025]={0};
    int n=recv(client, msg, 1024, 0);
    msg[1024]='\0';
    printf("%s\n",msg);
    
 
    struct timeval tval;
    tval.tv_sec=5;
    tval.tv_usec=0;
    select(0,NULL,NULL,NULL,&tval);
    
    return 0;
}
